// https://router.vuejs.org/zh/
import { createRouter, createWebHistory, type RouteRecordRaw } from "vue-router";
import NProgress from "nprogress";
import "nprogress/nprogress.css";

// 导入路由组件
import homeLayout from "@/views/layout-home/index.vue";
import walletLayout from "@/views/layout-wallet/index.vue";
import accessLayout from "@/views/layout-access/index.vue";
// import mock from "@/views/mock/index.vue";
// import charts from "@/views/charts/index.vue";
// import unocss from "@/views/unocss/index.vue";

NProgress.configure({ showSpinner: true, parent: "#app" });

// 定义路由，每个路由都需要映射到一个组件
const routes: Readonly<RouteRecordRaw[]> = [
  {
    path: "/",
    name: "home-layout",
    component: homeLayout,
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "home",
        component: () => import("@/views/home/index.vue")
      },
      {
        path: "/sweep",
        name: "sweep",
        component: () => import("@/views/sweep/index.vue")
      },
      {
        path: "/loading",
        name: "loading",
        component: () => import("@/views/sweep/loading.vue")
      },
        
      {
        path: "/more",
        name: "more",
        component: () => import("@/views/more/index.vue")
      },
      {
        path: "/person",
        name: "person",
        component: () => import("@/views/account/index.vue")
      },
      {
        path: "/global-setting",
        name: "global-setting",
        component: () => import("@/views/global-setting/index.vue")
      },
      {
        path: "/account",
        name: "account",
        component: () => import("@/views/person-center/index.vue")
      },
      {
        path: "/security",
        name: "security",
        component: () => import("@/views/security/index.vue")
      }
    ]
  },
  {
    path: "/",
    name: "wallet-layout",
    component: walletLayout,
    children: [
      {
        path: "/deposit",
        name: "deposit",
        component: () => import("@/views/deposit/index.vue")
      },
      {
        path: "/withdraw",
        name: "withdraw",
        component: () => import("@/views/withdraw/index.vue")
      }
    ]
  },
  {
    path: "/",
    name: "access-layout",
    component: accessLayout,
    children: [
      {
        path: "/login",
        name: "login",
        component: () => import("@/views/login/index.vue")
      },
      {
        path: "/forget",
        name: "forget",
        component: () => import("@/views/forget/index.vue")
      },
      {
        path: "/regist",
        name: "regist",
        component: () => import("@/views/regist/index.vue")
      }
    ]
  },

  {
    path: "/bounce",
    name: "bounce",
    component: () => import("@/views/bounce/index.vue")
  }, {
    path: "/2d-game",
    name: "2d-game",
    component: () => import("@/views/2d-game/index.vue")
  },
  {
    path: "/notification",
    name: "notification",
    component: () => import("@/views/notification/index.vue")
  },
  {
    path: "/vip-club",
    name: "vip-club",
    component: () => import("@/views/vip-club/index.vue")
  },
  {
    path: "/location",
    name: "location",
    component: () => import("@/views/location/index.vue")
  },
  {
    path: "/my-profile",
    name: "my-profile",
    component: () => import("@/views/my-profile/index.vue")
  },
  {
    path: "/phone-validate",
    name: "phone-validate",
    component: () => import("@/views/phone-validate/index.vue")
  },
  {
    path: "/code-validate",
    name: "code-validate",
    component: () => import("@/views/code-validate/index.vue")
  },
  {
    path: "/change-password",
    name: "change-password",
    component: () => import("@/views/change-password/index.vue")
  },
  {
    path: "/set-password",
    name: "set-password",
    component: () => import("@/views/set-password/index.vue")
  },
  {
    path: "/user-detail",
    name: "user-detail",
    component: () => import("@/views/user-detail/index.vue")
  },
  {
    path: "/master-medals",
    name: "master-medals",
    component: () => import("@/views/master-medals/index.vue")
  },
  {
    path: "/sic-bo",
    name: "sic-bo",
    component: () => import("@/views/sic-bo/index.vue")
  },
  {
    path: "/pk10",
    name: "pk10",
    component: () => import("@/views/pk10/index.vue")
  },
];

// 创建路由实例并传递 `routes` 配置
const router = createRouter({
  // eslint-disable-next-line node/prefer-global/process
  history: createWebHistory(process.env.VUE_APP_PUBLIC_PATH),
  routes
});

console.log(router);
router.beforeEach((_to, _from, next) => {
  NProgress.start(); // start progress bar
  next();
});

router.afterEach(() => {
  NProgress.done(); // finish progress bar
});

// 导出路由实例，并在 `main.ts` 挂载
export default router;
